package team.bluepen.order.web.servlet;

import team.bluepen.order.constant.Constant;
import team.bluepen.order.data.hdfs.PathPack;
import team.bluepen.order.data.hdfs.HdfsManager;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author RollW
 */
@WebServlet(name = "FileListServlet", urlPatterns = "/api/file/list")
public class FileListServlet extends BaseServlet {
    @Override
    protected void post(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<PathPack> uploadPaths = HdfsManager.getInstance()
                .listAllFile(Constant.UPLOAD_DIRECTORY);
        setJsonHeader(resp);
        writeJson(resp, uploadPaths);

    }


}
